﻿#region
/*******************************************************************************
** File Name:		    FeedStockService.cs
** Creator:		        chao.jiang 
** EMail:               chao.jiang 
** Create date:	        
** Latest Modifier:
** Latest Modify date:
** Description:		    
** Modify History:
**
** Code Review:
**
** Version number:       1.0.0
*********************************************************************************/
#endregion
using System;
using System.Collections.Generic;
using System.Text;
using EWineShop.Service.Contracts;
using EWineShop.Service.Model;
using EWineShop.IBatisRepository;
using EWineShop.Respository;
using System.Data;
using EWineShop.Entity;

namespace EWineShop.Service
{
    public class FeedStockService : IFeedStockService
    {
		 IFeedStock feedStock = new FeedStockRepository();
		 
		 #region  Auto Generation
		 

	
		public IList<FeedStockModel> GetAll ()
		{
			IList<EFeedStock> entity = feedStock.GetAll();
			
			if (entity == null)
            {
                return null;
            }
            
            IList<FeedStockModel> list = new List<FeedStockModel>();

            foreach (var item in entity)
            {
                FeedStockModel model = ConvertEntityToModel(item);
                list.Add(model);
            }
            return list;   
			
		}
		
		private FeedStockModel ConvertEntityToModel(EFeedStock entity)
		{
			if (entity == null)
            {
                return null;
            }
			FeedStockModel model = new FeedStockModel();
                        model.FeedStockID = entity.FeedStockID;
                        model.Code = entity.Code;
                        model.FeedStockTypeID = entity.FeedStockTypeID;
                        model.Name = entity.Name;
                        model.ChsSpell = entity.ChsSpell;
                        model.Unit = entity.Unit;
                        model.WarehouseUP = entity.WarehouseUP;
                        model.WarehouseDown = entity.WarehouseDown;
                        model.IsEnable = entity.IsEnable;
                        model.CreateTime = entity.CreateTime;
                        model.UpdateTime = entity.UpdateTime;
                        return model;
		}
		
		private EFeedStock ConvertModelToEntity(FeedStockModel model)
		{
			if (model == null)
            {
                return null;
            }
			EFeedStock entity = new EFeedStock();
                        entity.FeedStockID = model.FeedStockID;
                        entity.Code = model.Code;
                        entity.FeedStockTypeID = model.FeedStockTypeID;
                        entity.Name = model.Name;
                        entity.ChsSpell = model.ChsSpell;
                        entity.Unit = model.Unit;
                        entity.WarehouseUP = model.WarehouseUP;
                        entity.WarehouseDown = model.WarehouseDown;
                        entity.IsEnable = model.IsEnable;
                        entity.CreateTime = model.CreateTime;
                        entity.UpdateTime = model.UpdateTime;
                        return entity;
		}
		
		
		
		#endregion
    }
}